<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="用户名称" prop="pid">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="售后状态" prop="saleStatus">
        <el-select v-model="queryParams.saleStatus" placeholder="请选择">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <!-- 1 待售后 2 售后完成  orderStatus  -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5" style="font-size: 28px; font-weight: 500">
        <el-button @click="saleSearch(1)">待售后</el-button>
      </el-col>
      <el-col :span="1.5" style="font-size: 28px; font-weight: 500">
        <el-button @click="saleSearch(2)">售后中</el-button>
      </el-col>
      <el-col :span="1.5" style="font-size: 28px; font-weight: 500">
        <el-button @click="saleSearch(3)">售后完成</el-button>
      </el-col>
    </el-row>

    <el-row :gutter="30" class="mb8">
      <el-col :span="1.5" style="font-size: 28px; font-weight: 500">
        待售后：<span>{{ info.wait }}</span>
      </el-col>
      <el-col :span="1.5" style="font-size: 28px; font-weight: 500">
        售后中：<span style="color: red">{{ info.processing }}</span>
      </el-col>
      <el-col :span="1.5" style="font-size: 28px; font-weight: 500">
        售后完成：{{ info.finish }}
      </el-col>
    </el-row>

    <el-table
      border
      v-loading="loading"
      :data="goodsList"
      @selection-change="handleSelectionChange"
    >
      <!-- userName   createTime-->

      <el-table-column label="用户名称" align="center" prop="userName" />
      <el-table-column label="下单时间" align="center" prop="createTime" />
      <!--  -->
      <el-table-column label="商品名称" align="center" prop="title">
        <template slot-scope="scope">
          {{ scope.row.orderDetails[0].title }}
        </template>
      </el-table-column>
      <el-table-column label="订单号" align="center" prop="url">
        <template slot-scope="scope">
          <!-- <image-preview :src="scope.row.url" :width="50" :height="50" />
            -->
          {{ scope.row.orderCode }}
        </template>
      </el-table-column>
      <el-table-column label="快递单号" align="center" prop="pid">
        <template slot-scope="scope">
          {{ scope.row.waybillNo }}
        </template>
      </el-table-column>

      <el-table-column label="收货人姓名" align="center" prop="consigneeName">
        <template slot-scope="scope">
          {{ scope.row.orderConsignee.consigneeName }}
        </template>
      </el-table-column>
      <el-table-column label="收货人电话" align="center" prop="consigneeName">
        <template slot-scope="scope">
          {{ scope.row.orderConsignee.consigneePhone }}
        </template>
      </el-table-column>

      <el-table-column label="收货人地址" align="center" prop="createTime">
        <template slot-scope="scope">
          {{ scope.row.orderConsignee.consigneeAddress
          }}{{ scope.row.orderConsignee.addressDetailed }}
        </template>
      </el-table-column>

      <el-table-column label="售后状态" align="center" prop="createTime">
        <template slot-scope="scope">
          {{
            scope.row.saleStatus == 1
              ? "待售后"
              : scope.row.saleStatus == 2
              ? "售后中"
              : "售后完成"
          }}
        </template>
      </el-table-column>

      <el-table-column label="售后时间" align="center" prop="updateTime">
      </el-table-column>
      <!-- orderStatus -->
      <el-table-column label="物流状态" align="center" prop="createTime">
        <!-- 1 待发货 3 已发货 4 已收货 -->
        <template slot-scope="scope">
          <div v-if="scope.row.orderStatus == 1">未揽收</div>
          <div v-if="scope.row.orderStatus == 3">已揽收</div>
          <!-- {{scope.row.orderStatus == 1 ? '未揽收' : '已揽收' }} -->
        </template>
      </el-table-column>

      <!-- <el-table-column label="物流轨迹" align="center" prop="createTime">
        <template slot-scope="scope">
          <el-button type="primary" @click="lookWu(scope.row)">查看</el-button>
        </template>
      </el-table-column> -->

      <el-table-column label="快递类型" align="center" prop="createTime">
        <template slot-scope="scope">
          {{ scope.row.expressType == 2 ? "顺丰" : "圆通" }}
          <span :class="{ isRed: scope.row.expressType == 1 }">
            {{ scope.row.expressType == 2 ? "" : "(需客服确认是否取消)" }}</span
          >
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-popconfirm
            v-if="scope.row.saleStatus == 1"
            title="确认接收该订单"
            @confirm="receiveOrder(scope.row)"
          >
            <el-button
              slot="reference"
              size="mini"
              type="text"
              icon="el-icon-circle-check"
            >
              接收订单</el-button
            >
          </el-popconfirm>

          <el-popconfirm
            v-if="scope.row.saleStatus !== 3"
            title="确认拒绝该订单售后？"
            @confirm="refuseOrder(scope.row)"
          >
            <el-button
              slot="reference"
              size="mini"
              type="text"
              icon="el-icon-circle-close"
            >
              拒绝售后</el-button
            >
          </el-popconfirm>
          <el-popconfirm
            v-if="scope.row.saleStatus == 2"
            title="确认取消该订单"
            @confirm="cancelOrder(scope.row)"
          >
            <el-button
              slot="reference"
              size="mini"
              type="text"
              icon="el-icon-edit"
            >
              确认取消</el-button
            >
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改商品管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="分类" prop="pid">
          <el-select v-model="form.pid" placeholder="请选择分类">
            <el-option
              v-for="dict in typeDict"
              :key="dict.id"
              :label="dict.title"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入标题" />
        </el-form-item>
        <el-form-item label="图片" prop="url">
          <image-upload v-model="form.url" />
        </el-form-item>
        <el-form-item
          label="显示顺序
"
          prop="orderNum"
        >
          <el-input
            v-model="form.orderNum"
            placeholder="请输入显示顺序
"
          />
        </el-form-item>
        <el-form-item label="零售价" prop="price">
          <el-input v-model="form.price" placeholder="请输入零售价" />
        </el-form-item>
        <el-form-item label="库存" prop="store">
          <el-input-number
            :min="0"
            v-model="form.store"
            placeholder="请输入库存"
          />
        </el-form-item>
        <el-form-item label="预警库存" prop="warnStore">
          <el-input-number
            :min="0"
            v-model="form.warnStore"
            placeholder="请输入预警库存"
          />
        </el-form-item>
        <!-- 0 1 -->
        <el-form-item label="状态" prop="stutas">
          <!-- <el-input v-model="form.status" placeholder="请输入零售价" />
            -->

          <el-radio-group v-model="form.status">
            <el-radio :label="1">上架</el-radio>
            <el-radio :label="2">下架</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="详情">
          <editor v-model="form.remark" :min-height="192" />
        </el-form-item>

        <el-divider content-position="center">零售用户规格信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddgg"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteGg"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-table
          :data="ggList"
          :row-class-name="rowDengjiIndex"
          @selection-change="handleGgSelectionChange"
          border
          ref="dengji"
        >
          <el-table-column type="selection" align="center" />
          <el-table-column
            label="序号"
            align="center"
            prop="index"
            width="100"
          />
          <el-table-column label="商品规格" prop="name">
            <template slot-scope="scope">
              <el-input v-model="scope.row.name" placeholder="请输入规格" />
            </template>
          </el-table-column>
          <el-table-column label="商品规格价格" prop="price">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.price"
                placeholder="请输入商品价格"
              />
            </template>
          </el-table-column>
          <el-table-column label="商品库存" prop="store">
            <template slot-scope="scope">
              <el-input v-model="scope.row.store" placeholder="请输入库存" />
            </template>
          </el-table-column>
        </el-table>

        <!--  <el-divider content-position="center">等级价格信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAddDengji"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteDengji"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-table
          border
          :data="dengjiList"
          :row-class-name="rowDengjiIndex"
          @selection-change="handleDengjiSelectionChange"
          ref="dengji"
        >
          <el-table-column type="selection" align="center" />
          <el-table-column
            label="序号"
            align="center"
            prop="index"
            width="100"
          />
          <el-table-column label="用户等级" prop="title">
            <template slot-scope="scope">
              <el-select
                @change="changeYh(scope.row)"
                v-model="scope.row.title"
                style="width: 100%"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in yhList"
                  :key="item.userVip"
                  :label="item.userVip"
                  :value="item.userVip"
                >
                </el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="价格" prop="price">
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.price"
                placeholder="请输入商品价格"
              />
            </template>
          </el-table-column>
        </el-table> -->
        <el-divider content-position="center">代理用户规格信息</el-divider>
        <el-table
          border
          v-loading="loading"
          :data="form.goodsAgentList"
          style="width: 100%"
          ref="table"
        >
          <el-table-column label="用户等级" align="center" prop="userVip">
          </el-table-column>
          <el-table-column label="规格名称" align="center" prop="pid">
            <template slot-scope="scope">
              <el-input v-model="scope.row.name"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="规格价格" align="center" prop="pid">
            <template slot-scope="scope">
              <el-input v-model="scope.row.price"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="商品库存" prop="store">
            <template slot-scope="scope">
              <el-input-number
                :min="0"
                v-model="scope.row.store"
                placeholder="请输入库存"
              />
            </template>
          </el-table-column>

          <el-table-column label="预警库存" prop="store">
            <template slot-scope="scope">
              <el-input-number
                :min="0"
                v-model="scope.row.warnStore"
                placeholder="请输入库存"
              />
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" prop="pid">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="addGg(scope.row, scope.$index)"
                >新增</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                v-if="scope.row.remark == '1'"
                @click="deleteGg(scope.row, scope.$index)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改商品管理对话框 -->
    <el-dialog
      title="确认取消"
      :visible.sync="openCancel"
      width="30%"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="备注" prop="title">
          <el-input type="textarea" v-model="form.title" placeholder="备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitCancel">确 定</el-button>
        <el-button @click="openCancel = false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="物流状态"
      :visible.sync="openWl"
      width="40%"
      append-to-body
    >
      <el-timeline>
        <el-timeline-item
          v-for="(activity, index) in activities"
          :key="index"
          color="green"
          :timestamp="activity.processTime"
        >
          {{ activity.processInfo }}
        </el-timeline-item>
      </el-timeline>
    </el-dialog>
  </div>
</template>

<script>
import {
  listGoods,
  getGoods,
  delGoods,
  addGoods,
  updateGoods,
  listVip,
  listCate,
} from "@/api/api/goods";

import {
  dictList,
  getOrderList,
  getSaleList,
  cancel,
  saleCount,
  saleRefuse,
  saleProcess,
  getProcess,
} from "@/api/api/cate";

export default {
  name: "Goods",
  dicts: ["user_vip"],
  data() {
    return {
      openWl: false,
      openCancel: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedDengji: [],
      checkedgg: [],
      cateList: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      activities: [],
      // 商品管理表格数据
      goodsList: [],
      // 等级价格表格数据
      dengjiList: [],
      ggList: [],
      options: [
        {
          value: 1,
          label: "待售后",
        },
        {
          value: 2,
          label: "售后中",
        },
        {
          value: 3,
          label: "售后完成",
        },
        {
          value: "",
          label: "全部",
        },
      ],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        pid: null,
        title: null,
        userName: "",
        // orderStatus: "",
        saleStatus: "",
      },
      // 表单参数
      form: {},
      yhList: [],
      // 表单校验
      rules: {
        pid: [{ required: true, message: "分类不能为空", trigger: "change" }],
        title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
        url: [{ required: true, message: "图片不能为空", trigger: "blur" }],
        price: [{ required: true, message: "零售价不能为空", trigger: "blur" }],
        updateTime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" },
        ],
        store: [
          {
            required: true,
            message: "库存不能为空",
            trigger: ["blur", "change"],
          },
        ],
        warnStore: [
          {
            required: true,
            message: "库存不能为空",
            trigger: ["blur", "change"],
          },
        ],
      },
      typeDict: [],
      info: {},
    };
  },
  created() {
    this.getList();
    this.getYhList();
    this.getFlList();
    this.getSaleCount();
    dictList().then((res) => {
      this.typeDict = res.data;
    });
  },
  methods: {
    //查看物流
    lookWu(val) {
      this.activities = [];
      getProcess(val.id).then((res) => {
        if (res.code == 200) {
          this.openWl = true;
          this.activities = res.data.data;
        } else {
          this.$toast(res.data.message);
        }
      });
    },
    saleSearch(type) {
      this.queryParams.saleStatus = type;
      this.getList();
    },
    getSaleCount() {
      saleCount().then((res) => {
        console.log(res, "asdasdasdasd");
        this.info = res.data;
      });
    },

    // 接收订单
    receiveOrder(val) {
      console.log(val, "sssssssssss");
      saleProcess(val.id).then((res) => {
        this.$message({
          message: "接收成功",
          type: "success",
        });
        this.getList();
      });
    },
    refuseOrder(val) {
      saleRefuse(val.id).then((res) => {
        this.getList();
      });
    },
    getFlList() {
      this.loading = true;
      // listCate(this.queryParams).then((response) => {
      //   this.cateList = response.rows;
      // });
    },
    changeYh(val) {
      val.userId = this.yhList.find((i) => i.userVip == val.title).id;
    },
    /** 查询商品管理列表 */
    getList() {
      this.loading = true;
      // this.queryParams.saleStatus = 3;
      getSaleList(this.queryParams).then((response) => {
        this.goodsList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.getSaleCount();
      });
    },
    // 获取用户等级
    getYhList() {
      listVip().then((res) => {
        console.log(res, "asdasdasda");
        this.yhList = res.rows;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        pid: null,
        title: null,
        url: null,
        orderNum: null,
        price: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        text: [],
        status: 1,
      };
      this.dengjiList = [];
      this.ggList = [];
      this.resetForm("form");
    },
    submitCancel() {
      this.openCancel = false;
    },
    cancelOrder(val) {
      // this.openCancel = true;
      cancel(val).then((res) => {
        this.getList();
        this.getSaleCount();
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.form.goodsAgentList = [];
      console.log(this.yhList, "this.yhList");
      this.yhList.forEach((element) => {
        let params = {
          userVipId: element.id,
          userVip: element.userVip,
        };

        this.form.goodsAgentList.push(params);
      });
      console.log(this.form.goodsAgentList, "this.form.goodsAgentList");
      this.title = "添加商品管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getGoods(id).then((response) => {
        this.form = response.data;
        // this.form.text1 = JSON.parse(this.form.text1);
        // let arr = this.findMissingUserVip(this.form.text1, this.yhList);
        // if (arr.length > 0) {
        //   arr.forEach((i) => {
        //     this.form.text1.push(i);
        //   });
        // }
        this.form.goodsAgentList = this.updateUserList(
          this.form.goodsAgentList,
          this.yhList
        );
        this.dengjiList = response.data.dengjiList;
        this.ggList = response.data.goodsinfoList;
        this.open = true;
        this.title = "修改商品管理";
      });
    },

    updateUserList(user, yhList) {
      // 1. 将user数组中缺少的数据添加进去
      yhList.forEach((item) => {
        if (!user.some((u) => u.userVip === item.userVip)) {
          user.push({ userVip: item.userVip, price: "", name: "", remark: "" });
        }
      });

      // 2. 删除user数组中多余的数据
      user = user.filter((u) =>
        yhList.some((item) => item.userVip === u.userVip)
      );

      return user;
    },

    removeMissingUserVip(array1, array2) {
      const userVipSet = new Set(array1.map((item) => item.userVip));
      const filteredArray2 = array2.filter((item) =>
        userVipSet.has(item.userVip)
      );
      return filteredArray2;
    },

    findMissingUserVip(array1, array2) {
      const missingUserVip = array2.filter(
        (item2) => !array1.some((item1) => item1.userVip === item2.userVip)
      );
      return missingUserVip;
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.form.dengjiList = this.dengjiList;
          this.form.goodsinfoList = this.ggList;
          // this.form.text1 = JSON.stringify(this.form.text1);
          if (this.form.id != null) {
            updateGoods(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGoods(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    addGg(val, index) {
      let params = {
        name: "",
        price: "",
        userVip: val.userVip,
        userVipId: val.userVipId,
        remark: "1",
        id: "",
        store: "",
        warnStore: 0,
      };
      console.log(params, "params1111");
      this.form.goodsAgentList.splice(index + 1, 0, params);
      // 设置新增数据的用户等级字段
      // 重新渲染表格，以确保合并后的单元格数据可见
      // this.$nextTick(() => {
      //   this.$refs.table.doLayout();
      // });
    },
    deleteGg(row, index) {
      this.form.goodsAgentList.splice(index, 1);
    },

    mergeCells({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        if (
          rowIndex > 0 &&
          row.userVip === this.form.goodsAgentList[rowIndex - 1].userVip
        ) {
          return {
            rowspan: 0,
            colspan: 0,
            userVip: this.form.goodsAgentList[rowIndex - 1].userVip,
          };
        }
        let count = 1;
        for (let i = rowIndex + 1; i < this.form.goodsAgentList.length; i++) {
          if (row.userVip === this.form.goodsAgentList[i].userVip) {
            count++;
          } else {
            break;
          }
        }
        return {
          rowspan: count,
          colspan: 1,
        };
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除商品管理编号为"' + ids + '"的数据项？')
        .then(function () {
          return delGoods(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 等级价格序号 */
    rowDengjiIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 等级价格添加按钮操作 */
    handleAddDengji() {
      let obj = {};
      obj.title = "";
      obj.price = "";
      this.dengjiList.push(obj);
    },
    handleAddgg() {
      let obj = {};
      obj.name = "";
      obj.price = "";
      this.ggList.push(obj);
    },
    /** 等级价格删除按钮操作 */
    handleDeleteDengji() {
      if (this.checkedDengji.length == 0) {
        this.$modal.msgError("请先选择要删除的等级价格数据");
      } else {
        const dengjiList = this.dengjiList;
        const checkedDengji = this.checkedDengji;
        this.dengjiList = dengjiList.filter(function (item) {
          return checkedDengji.indexOf(item.index) == -1;
        });
      }
    },

    handleDeleteGg() {
      if (this.checkedgg.length == 0) {
        this.$modal.msgError("请先选择要删除的等级价格数据");
      } else {
        const ggList = this.ggList;
        const checkedgg = this.checkedgg;
        this.ggList = ggList.filter(function (item) {
          return checkedgg.indexOf(item.index) == -1;
        });
      }
    },

    /** 复选框选中数据 */
    handleDengjiSelectionChange(selection) {
      this.checkedDengji = selection.map((item) => item.index);
    },

    handleGgSelectionChange(selection) {
      this.checkedgg = selection.map((item) => item.index);
    },

    handleDeleteDengji() {
      if (this.checkedDengji.length == 0) {
        this.$modal.msgError("请先选择要删除的等级价格数据");
      } else {
        const dengjiList = this.dengjiList;
        const checkedDengji = this.checkedDengji;
        this.dengjiList = dengjiList.filter(function (item) {
          return checkedDengji.indexOf(item.index) == -1;
        });
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "api/goods/export",
        {
          ...this.queryParams,
        },
        `goods_${new Date().getTime()}.xlsx`
      );
    },
    rowClassName({ row, rowIndex }) {
      console.log(row, "111111");
      return row.alarm === 1 ? "alarm-row" : "";
    },
  },
};
</script>
<style>
.alarm-row {
  background-color: #f56c6c !important;
}
.isRed {
  color: red;
}
</style>
